import { post, get, postFormData } from "../api";
// import qs from "qs"; // 根据需求是否导入qs模块(用来序列化post类型的数据)

const home = {
    //获取首页左边栏数据
    getLeftEntriesApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/entry/getLeftEntries", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //获取卡片列表
    getEntriesApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/entry/getEntries", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //新增卡片接口
    saveEntryApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/entry/saveEntry", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },

    //删除/还原多条卡片接口
    deleteMultipleEntriesApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/entry/deleteMultipleEntries", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },

    //修改卡片接口
    updateEntryApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/entry/updateEntry", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },

    //上传txt
    importTxtApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/entry/importTxt", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },

    //上传sqlite
    importSqliteApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/entry/importSqlite", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
}

export default home 